package com.kid.keep.dao.user;

import com.kid.keep.po.User;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

/**
 * @Description User dao
 * @Author JOHN
 * @Create 2019-01-10
 * @Since 1.0.0
 */
@Repository
public class UserRepository extends ServiceImpl<IUserMapper, User> implements IUserRepository {


    @Override
    public User findByOpenIdAndAppId(String openId,Long appId) {
        return this.baseMapper.selectOne(new QueryWrapper<User>().lambda().eq(User::getOpenId, openId).eq(User::getAppId, appId));

    }

    @Override
    public User  findByIdAndAppId(Long userId,Long appId){
        return this.baseMapper.selectOne(new QueryWrapper<User>().lambda().eq(User::getId, userId).eq(User::getAppId,appId));
    }

    @Override
    public User findById(Long userId) {
        return this.baseMapper.selectOne(new QueryWrapper<User>().lambda().eq(User::getId, userId));
    }
}


